package helper

import "encoding/json"

func MapToStruct[T any](m map[string]interface{}) (T, error) {
	var result T
	buf, err := json.Marshal(m)
	if err != nil {
		return result, err
	}
	err = json.Unmarshal(buf, &result)
	if err != nil {
		return result, err
	}
	return result, nil
}
